package com.xmh.ssm.other;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.xmh.ssm.dao.TestXmlDao;
//import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

//@RunWith(SpringJUnit4ClassRunner.class)
//@ContextConfiguration("classpath:spring_bean.xml")
public class FirebirdTest {

	@Resource(name = "dataSource")
	private ComboPooledDataSource comboPooledDataSource;

	@Value("${driverClass}")
	private String driverClass;

	@Value("${jdbcUrl}")
	private String jdbcUrl;

	@Value("${user}")
	private String user;

	@Value("${password}")
	private String password;

	@Value("${initialPoolSize}")
	private String initialPoolSize;

	@Value("${maxPoolSize}")
	private String maxPoolSize;

	@Value("${minPoolSize}")
	private String minPoolSize;

	@Resource
	private TestXmlDao TestxmlDao = null;

//	@Test
	public void test1() {
		try {
			System.out.println(password);
			insert();
//			System.out.println(TestxmlDao.selectAll());
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	private int insert() throws ClassNotFoundException, SQLException {
		Connection conn = comboPooledDataSource.getConnection();

		PreparedStatement ps = conn.prepareStatement("select * from t_test_test  ");
		ResultSet rs = ps.executeQuery();
		while (rs.next()) {
			String id = rs.getString("id");
			System.out.println(id);
		}
//
//		PreparedStatement pstmt;
//		try {
//			pstmt = (PreparedStatement) conn.prepareStatement(sql);
//
//			pstmt.setInt(1, 23);
//
//			pstmt.setString(2, "test");
//
//			i = pstmt.executeUpdate();
//
//			pstmt.close();
//
//			conn.close();
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
		return 1;
	}

}
